package com.efast.dmom.mgmt.controller.mes.plan;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.dmom.mgmt.bean.mes.InfPpPlan;
import com.efast.dmom.mgmt.bean.mes.MesCalendarShiftRelation;
import com.efast.dmom.mgmt.service.mes.plan.PlanAutoScheduleService;
import com.efast.dmom.mgmt.service.mes.plan.impl.PlanningSchedulingService;

@Controller
@RequestMapping("/planScheduling")
public class PlanningSchedulingController {
	@Autowired
	private PlanningSchedulingService pss;
	
	@Autowired
	private PlanAutoScheduleService autoScheduleService;
	
	@RequestMapping(value = "/setOlineDate", method=RequestMethod.POST)
	public @ResponseBody ResultBean autoSetOlineDate(@RequestBody List<InfPpPlan> plans) {
//		return pss.autoSetOlineDate(plans);
		
		ResultBean fixPlanOnlineDateList = autoScheduleService.fixPlanOnlineDateList(plans);
		
		
		return fixPlanOnlineDateList;
	}
	@RequestMapping(value = "/querySchedulingDateResult/{date}", method=RequestMethod.POST)
	public @ResponseBody ResultBean querySchedulingDateResult(@PathVariable String date) {
		
		String str = date.replaceAll("-", "/");
		
		@SuppressWarnings("deprecation")
		Date dt = new Date(str);
		return pss.querySchedulingDateResult(dt);
	}
}
